const Koa = require('koa')
const Router = require('koa-router')

const path = require('path')

const json = require('koa-json')
const KoaBody = require('koa-body')
const logger = require('koa-logger')

const proxy = require('koa-proxies')
const app = new Koa()
const router = new Router()

app.use(proxy('/access-server', {
  target: 'http://192.168.0.98:8080',
  changeOrigin: true,
}))

// middlewares
app.use(KoaBody())
app.use(json())
app.use(logger())
// app.use(async (ctx, next) => {
//   if (ctx.path === '/') ctx.redirect('/vue/dist/index.html#/search')
//   await next()
// })
app.use(require('koa-static')(path.join(__dirname, '../dist/')))



app.use(router.routes(), router.allowedMethods()).listen("4455")
